import { reactive } from 'vue'
import { VxeGridProps } from 'vxe-table'

interface Rows {
  // id: string
  // technologySecretName: string
  // inventorsPeople: string
  // date: string
  // inventor: string
  // unit: string
  // submitDate: string
}

const gridOptions = reactive<VxeGridProps>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  columns: [
    { field: 'id', title: '技术秘密编号' },
    { field: 'technologySecretName', title: '技术秘密名称' },
    // { field: 'secretsType', title: '技术秘密类型' },
    {
      field: 'inventors',
      title: '发明人',
      formatter({ cellValue }) {
        let list = JSON.parse(cellValue || '[]')
        let people = list.map((item) => {
          if (item.contributeProportion) {
            return item.name + '(' + item.contributeProportion + '%)'
          } else {
            return item.name
          }
        })
        return people.join('、')
      },
    },
    { field: 'completeUnit', title: '完成单位' },
    { field: 'createTime', title: '提交日期' },
    { title: '操作', width: 300, slots: { default: 'operate' } },
  ],
  data: [],
})

const descriptions = reactive([
  {
    label: '技术秘密名称：',
    value: 'technologySecretName',
  },
  {
    label: '完成单位：',
    value: 'completeUnit',
  },
  {
    label: '提交日期：',
    value: 'createTime',
  },
])

const operationLog = reactive<VxeGridProps>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  columns: [
    { field: 'type', title: '操作类型', width: 200 },
    { field: 'name', title: '操作员', width: 200 },
    { field: 'content', title: '操作内容' },
    { field: 'date', title: '操作时间', width: 200 },
  ],
  toolbarConfig: {
    slots: {
      buttons: 'toolbar_buttons',
    },
  },
  data: [
    {
      type: '修改状态',
      name: '曲丽丽',
      content: '修改了“软件名称”',
      date: '2023-01-01 00:00:00',
    },
    {
      type: '新增信息',
      name: '周毛毛',
      content: '新增软著信息',
      date: '2023-01-01 00:00:00',
    },
  ],
})

const patentPeople = reactive<VxeGridProps>({
  border: true,
  height: 300,
  align: 'center',
  loading: false,
  columnConfig: {
    resizable: true,
  },
  editConfig: {
    // trigger: 'manual',
    // mode: 'row',
    // showStatus: true,
  },
  columns: [
    { title: '序号', type: 'seq', width: 50 },
    {
      field: 'name',
      title: '姓名',
    },
    {
      field: 'mobile',
      title: '手机号',
    },
    {
      field: 'employeeCode',
      title: '员工编号',
    },
    {
      field: 'contributeProportion',
      title: '贡献率',
    },
    // { title: '操作', width: 300, slots: { default: 'operate' } },
  ],
  toolbarConfig: {},
  data: [
    {
      patentName: 'xxx',
      patentPhone: '177xxxxxxx',
      patentType: '233xxx',
      date: '10',
    },
  ],
})

export { gridOptions, descriptions, operationLog, patentPeople }
